package com.smartlbs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smartlbs.baseframe.utils.ConfigFileUtils;
import com.smartlbs.baseframe.web.ResponseInfo;
import com.smartlbs.service.ISettingService;
import com.smartlbs.util.ConfigUtil;

@Controller
@RequestMapping("setting")
public class SettingController {

	@Autowired
	private ISettingService settingService;
	
	/**
	 * 设置信息
	 * 
	 * 
	 * 
	 * @param type
	 * @param info
	 * @return
	 */
	@RequestMapping("set")
	@ResponseBody
	public ResponseInfo setting(Integer type, String info){
		
		int result = 0;
		String message = "";
		
		try {
			settingService.setting(type, info);
			
			result = 1;
			message = "设置成功";
		} catch (Exception e) {
			message = "设置失败";
			e.printStackTrace();
		}
		
		ResponseInfo responseInfo = new ResponseInfo();
		
		responseInfo.setResult(result);
		responseInfo.setMessage(message);
		
		return responseInfo;
	}
	
	/**
	 * 设置获取信息
	 * 
	 * 
	 * 
	 * @param type
	 * @param info
	 * @return
	 */
	@RequestMapping("get")
	@ResponseBody
	public ResponseInfo get(String types){
		
		int result = 0;
		String message = "";
		Object data = null;
		
		try {
			data = settingService.getSetting(types);
			
			result = 1;
			message = "信息获取成功";
		} catch (Exception e) {
			message = "信息获取失败";
			e.printStackTrace();
		}
		
		ResponseInfo responseInfo = new ResponseInfo();
		
		responseInfo.setResult(result);
		responseInfo.setMessage(message);
		responseInfo.setData(data);
		
		return responseInfo;
	}
}
